#include "DbPool.h"
#include <unistd.h>

int add(int a, int b)
{
    // cout << a << " + " << b << " = " << a + b << endl;
    return a + b;
}
int sub(int a, int b, int c)
{
    return a - b - c;
}
void test_func()
{
    Dbp pool(3);
    future<int> ret;
    for (int i = 0; i < 10; i++)
    {
        ret = pool.Push(bind(add, 1, i));
        cout << ret.get() << endl;
        ret = pool.Push(bind(sub, 1, 1, i));
        cout << ret.get() << endl;
    }
}
void mysql_insert()
{
    Dbp pool(5);
    future<int> ret;
    string insert_sql = "insert into test value(6,'ynh','20')";
    ret = pool.Push(bind(mysql_query, pool._msq, insert_sql.c_str()));
    if (ret.get() == 0)
    {
        cout << "mysql_query insert success..." << endl;
    }
}
void mysql_select()
{
    Dbp pool(3);
    future<int> ret;
    string select_sql = "select * from test";
     ret = pool.Push(bind(mysql_query, pool._msq, select_sql.c_str()));
    if (ret.get() == 0)
    {
        cout << "mysql_query insert success..." << endl;
    }
}
int main()
{
    // test_func();
    mysql_insert();
}